<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Performs an extended operation</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.ldap-exop" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ldap_exop</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0)</p><p class="refpurpose"><span class="refname">ldap_exop</span> &mdash; <span class="dc-title">Performs an extended operation</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ldap-exop-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ldap_exop</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$reqoid</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$reqdata</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$serverctrls</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$retdata</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$retoid</code></span>
  ]]]] ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   Performs an extended operation on the specified <code class="parameter">link</code> with
   <code class="parameter">reqoid</code> the OID of the operation and
   <code class="parameter">reqdata</code> the data.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ldap-exop-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<code class="parameter">link</code></dt>

    <dd>

     <p class="para">
       An LDAP link identifier, returned by <span class="function"><a href="ldap_connect.html" class="function">ldap_connect()</a></span>.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">reqoid</code></dt>

    <dd>

     <p class="para">
       The extended operation request OID. You may use one of <strong><code>LDAP_EXOP_START_TLS</code></strong>, <strong><code>LDAP_EXOP_MODIFY_PASSWD</code></strong>, <strong><code>LDAP_EXOP_REFRESH</code></strong>, <strong><code>LDAP_EXOP_WHO_AM_I</code></strong>, <strong><code>LDAP_EXOP_TURN</code></strong>, or a string with the OID of the operation you want to send.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">reqdata</code></dt>

    <dd>

     <p class="para">
       The extended operation request data. May be NULL for some operations like <strong><code>LDAP_EXOP_WHO_AM_I</code></strong>, may also need to be BER encoded.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">serverctrls</code></dt>

    <dd>

     <p class="para">
      Array of <a href="ldap.controls.html" class="link">LDAP Controls</a> to send with the request.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">retdata</code></dt>

    <dd>

     <p class="para">
       Will be filled with the extended operation response data if provided.
       If not provided you may use ldap_parse_exop on the result object
       later to get this data.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">retoid</code></dt>

    <dd>

     <p class="para">
       Will be filled with the response OID if provided, usually equal to the request OID.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ldap-exop-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   When used with <code class="parameter">retdata</code>, returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on error.
   When used without <code class="parameter">retdata</code>, returns a result identifier or <strong><code>FALSE</code></strong> on error.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.ldap-exop-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.3</td>
       <td>
        Support for <code class="parameter">serverctrls</code> added
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ldap-exop-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5398">
    <p><strong>Example #1 Whoami extended operation</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$ds&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">);&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;assuming&nbsp;the&nbsp;LDAP&nbsp;server&nbsp;is&nbsp;on&nbsp;this&nbsp;host<br /><br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;bind&nbsp;with&nbsp;appropriate&nbsp;dn&nbsp;to&nbsp;give&nbsp;update&nbsp;access<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$bind&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"cn=root,&nbsp;o=My&nbsp;Company,&nbsp;c=US"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"secret"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #0000BB">$bind</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Unable&nbsp;to&nbsp;bind&nbsp;to&nbsp;LDAP&nbsp;server"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Call&nbsp;WHOAMI&nbsp;EXOP<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_exop</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">LDAP_EXOP_WHO_AM_I</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Parse&nbsp;the&nbsp;result&nbsp;object<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ldap_parse_exop</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$r</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$retdata</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Output:&nbsp;string(31)&nbsp;"dn:cn=root,&nbsp;o=My&nbsp;Company,&nbsp;c=US"<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$retdata</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Same&nbsp;thing&nbsp;using&nbsp;$retdata&nbsp;parameter<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$success&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_exop</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">LDAP_EXOP_WHO_AM_I</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$retdata</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$retoid</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$success</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$retdata</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ldap_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">);<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Unable&nbsp;to&nbsp;connect&nbsp;to&nbsp;LDAP&nbsp;server"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ldap-exop-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="ldap_parse_result.html" class="function" rel="rdfs-seeAlso">ldap_parse_result()</a> - Extract information from result</span></li>
    <li class="member"><span class="function"><a href="ldap_parse_exop.html" class="function" rel="rdfs-seeAlso">ldap_parse_exop()</a> - Parse result object from an LDAP extended operation</span></li>
    <li class="member"><span class="function"><a href="ldap_exop_whoami.html" class="function" rel="rdfs-seeAlso">ldap_exop_whoami()</a> - WHOAMI extended operation helper</span></li>
    <li class="member"><span class="function"><a href="ldap_exop_refresh.html" class="function" rel="rdfs-seeAlso">ldap_exop_refresh()</a> - Refresh extended operation helper</span></li>
    <li class="member"><span class="function"><a href="ldap_exop_passwd.html" class="function" rel="rdfs-seeAlso">ldap_exop_passwd()</a> - PASSWD extended operation helper</span></li>
   </ul>
  </p>
 </div>



</div></div></div></body></html>